package com.zzyl.controller;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.ApplicationsDto;
import com.zzyl.dto.PendingTasksDto;
import com.zzyl.entity.PendingTasks;
import com.zzyl.service.ActFlowCommService;
import com.zzyl.utils.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sjqn
 * @date 2023/11/9
 */
@RestController
@RequestMapping("/applications")
public class ApplicationsController {

    @Autowired
    private ActFlowCommService actFlowCommService;


    @PostMapping("/selectByPage")
    public ResponseResult selectByPage(@RequestBody ApplicationsDto applicationsDto){

        PendingTasksDto pendingTasksDto = BeanUtil.toBean(applicationsDto, PendingTasksDto.class);

        //获取用户
        Long mgtUserId = UserThreadLocal.getMgtUserId();
        pendingTasksDto.setApplicatId(mgtUserId);//申请人

        PageResponse<PendingTasks> myTaskList = actFlowCommService.getMyTaskList(pendingTasksDto);
        return ResponseResult.success(myTaskList);
    }
}
